﻿using Lapis.Share;
using Lapis.Shell.Events;
using Prism.Commands;
using System.Collections.Generic;

namespace Lapis.Shell.ViewModels
{
    /// <summary>
    /// 侧边菜单内容视图模型
    /// </summary>
    public class SideMenuContentViewModel : BaseViewModel
    {
        private DelegateCommand<string> _menuSelectedCommand;

        private List<PageInfo> _pages = new()
        {
            new PageInfo { Id = "1" ,RegionName = "RegionOne", DisplayName = "子菜单1" },
            new PageInfo { Id = "2", RegionName = "RegionTwo", DisplayName = "子菜单2" },
            new PageInfo { Id = "3", RegionName = "RegionThree", DisplayName = "子菜单3" },
        };

        public DelegateCommand<string> MenuSelectedCommand => _menuSelectedCommand ??= new DelegateCommand<string>(ExecuteMenuSelectedCommand);

        private void ExecuteMenuSelectedCommand(string id)
        {
            var info = _pages.Find(x => x.Id == id);
            if (info != null)
            {
                EventAggregator.GetEvent<PageSelectedEvent>().Publish(info);
            }
        }
    }
}